package com.phkj.qdh.ui.adapter

import android.content.Context
import android.view.ViewGroup
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.phkj.qdh.R
import com.phkj.qdh.bean.LawOrTeamInspectBean

class TeamSortAdapter:BaseQuickAdapter<LawOrTeamInspectBean,QuickViewHolder>() {
    override fun onBindViewHolder(
        holder: QuickViewHolder,
        position: Int,
        item: LawOrTeamInspectBean?
    ) {
        val iv = holder.getView<ImageView>(R.id.iv_bg)
        when(position%7){
            0->{
                Glide.with(context)
                    .load(R.mipmap.img_bg1)
                    .into(iv)
            }
            1->{
                Glide.with(context)
                    .load(R.mipmap.img_bg2)
                    .into(iv)
            }
            2->{
                Glide.with(context)
                    .load(R.mipmap.img_bg3)
                    .into(iv)
            }
            3->{
                Glide.with(context)
                    .load(R.mipmap.img_bg4)
                    .into(iv)
            }
            4->{
                Glide.with(context)
                    .load(R.mipmap.img_bg5)
                    .into(iv)
            }
            5->{
                Glide.with(context)
                    .load(R.mipmap.img_bg6)
                    .into(iv)
            }
            6->{
                Glide.with(context)
                    .load(R.mipmap.img_bg7)
                    .into(iv)
            }
        }

        val ivTitle = holder.getView<ImageView>(R.id.iv_title)
        holder.setText(R.id.tv_title,item?.name)
        when (item?.name) {
            "警容" -> { ivTitle.setImageResource(R.mipmap.icon_jingrong) }
            "车容"->{ ivTitle.setImageResource(R.mipmap.icon_cherong)}
            "所容"->{ ivTitle.setImageResource(R.mipmap.icon_suorong)}
            "垃圾分类"->{ ivTitle.setImageResource(R.mipmap.icon_laji)}
            "警纪警规"->{ ivTitle.setImageResource(R.mipmap.icon_jinggui)}
            "其他"->{ ivTitle.setImageResource(R.mipmap.icon_qita)}
            else -> {ivTitle.setImageResource(R.mipmap.icon_qita)}
        }

    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_inspect_type_select, parent)
    }
}